package com.commonsware.android.Now;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CheckBox;
import java.util.Date;

public class Now extends Activity implements CompoundButton.OnCheckedChangeListener {
	Button btn;
	CheckBox cb;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        btn = (Button)findViewById(R.id.button);
        updateTime();
        
        cb = (CheckBox)findViewById(R.id.check);
        cb.setOnCheckedChangeListener(this);
        cb.setChecked(true);
    }
    
    public void buttonClick(View view) {
    	updateTime();
   	}
    
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   		btn.setEnabled(isChecked);
    	if (isChecked) {
    		cb.setText("This checkbox is: checked");
   		} else {
    		cb.setText("This checkbox is: unchecked");
    	}
    }
    
    public void exitClick(View view) {
    	finish();
    }
    
    private void updateTime() {
    	btn.setText(new Date().toString());
    }
}